"""
Tests for utils module
"""
import unittest
from math import e

from semilla import Ln
from convert import conv

class SemillaTest(unittest.TestCase):
    def test_basic_ln(self):
        """
        Tests that Ln(e) is 1.
        """
        self.assertEqual(Ln(e), 1)

class ConvTest(unittest.TestCase):
    signum = 5
    def test_same_unit(self):
        """
        Tests that convert val from an unit to the same, should be the same val
        """
        val = 1
        units = ['d', 'h', 's', 'ls']
        for u in units:
            self.assertEqual(round(conv(val,u,u), self.signum), round(val, self.signum))
    def test_conv_d_h(self):
        """
        Tests to convert a value from day to hour
        """
        val = 10
        self.assertEqual(round(conv(val, "h", "d"), self.signum), round(240, self.signum))
    def test_conv_h_d(self):
        """
        Tests to convert a value from hour to day
        """
        val = 10
        self.assertEqual(round(conv(val, "d", "h"), self.signum), round(10.0 / 24.0, self.signum))
    def test_conv_s_d(self):
        """
        Tests to convert a value from second to day
        """
        val = 10
        self.assertEqual(round(conv(val, "d", "s"), self.signum), round(10.0/(24.0*60*60), self.signum))
    def test_conv_ls_d(self):
        """
        Tests to convert a value from L/s to day
        """
        val = 10
        self.assertEqual(round(conv(val, "d", "ls"), self.signum), round(10.0*1000/(24.0*60*60), self.signum))
    def test_conv_ls_h(self):
        """
        Tests to convert a value from L/s to hour
        """
        val = 10
        self.assertEqual(round(conv(val, "h", "ls"), self.signum), round(10.0*1000/(60*60), self.signum))
    def test_conv_s_h(self):
        """
        Tests to convert a value from seconds to hours
        """
        val = 10
        self.assertEqual(round(conv(val, "h", "s"), self.signum), round(10.0/(60*60), self.signum))
